import Vuex from 'vuex'
import Vue from 'vue'
Vue.use(Vuex)

const store = new Vuex.Store({
    state: {
        routes: []
    },
    mutations: { // 同步
        setRoutes(state, routes) {
            state.routes = routes
        },
        clearRoutes(state) {
            state.routes = []
        }
    },
    actions: { // 异步方法
        setRoleAction(context, routes) {
            context.commit('setRoutes', routes)
        }
    }
})

export default store